﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AassignUser.aspx.cs" Inherits="XYTXL.View.AassignUser" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="/View/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="/View/JS/zTree_v3/css/zTreeStyle/zTreeStyle.css" />
    <script src="/View/JS/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="/View/JS/zTree_v3/js/jquery.ztree.core-3.5.min.js"></script>
    <script type="text/javascript" src="/View/JS/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script>


    <script type="text/javascript">
        var zNodes = null;
        var zTreeObj = null;
        var setting = {
            data: {
                simpleData: {
                    enable: true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: 0
                }
            },
            check: {
                enable: true,
                chkStyle: "checkbox",
                chkboxType: { "Y": "ps", "N": "ps" }
            },
            view: {
                showLine: false
            },
            callback: {
                onCheck: zTreeOnCheck
            }
        };
        $(document).ready(function () {
            $.ajax({
                type: "POST",
                url: "AdminHandle.ashx",
                dataType: "html",
                data: { "CheckNodes": $("#hidCheckNodes").val(), "Action": "GetBranchUser" },
                beforeSend: function (XMLHttpRequest) {
                    parent.MyDialog.Mytips();
                },
                success: function (msg) {
                    zNodes = eval(msg);
                    zTreeObj = $.fn.zTree.init($("#tree"), setting, zNodes);
                },
                complete: function (XMLHttpRequest, textStatus) {
                    parent.MyDialog.CloseMytips();
                },
                error: function () {
                }
            });
        })


        function zTreeOnCheck(event, treeId, treeNode) {
            var checknodes = zTreeObj.getCheckedNodes(true);
            var s = "";
            $.each(checknodes, function (i, n) {
                var check = (n && n.isUser == "Y");
                if (check) {
                    s = s + n.id + ',';
                }
            });
            $("#hidCheckNodes").val(s);
        }

    </script>
</head>
<body style="margin: 0px">
    <form id="form" runat="server">

        <div id="sidebar" class="well" style="padding: 20px; margin: 20px">
            <div>
                <ul id="tree" class="ztree"></ul>
            </div>
            <div style="height: 30px;">
                <asp:Button ID="btAssignMenu" CssClass="btn btn-success btn-large" runat="server" Text="确认"
                    OnClick="btAssignMenu_Click" />
                &nbsp;&nbsp;&nbsp;
            </div>
        </div>

        <input id="hidCheckNodes" type="hidden" value="" runat="server" />

    </form>
</body>
</html>
